Getting Started with Open CV

We use the sklearn image dataset to demonstrate basic operations using Open CV.

Accessing and Modifying pixel values

We can use split funtion to access various channels of an image.

Alternatively, we could use, for example, use Img[:,:,0], Img[:,:,1] and Img[:,:,2] to access the red, green and blue chanells of Img.

Adding Pading

For more information, please see the offical documentation here.

Image Blending

Image blending can be done using cv2.addWeighted. This function blends two images as follows

$$\text{Output Image} = \alpha\,\text{Image1} + (1-\alpha)\, \text{Image2} + \gamma$$

where $0\leq \alpha\leq 1$ and $\gamma$ is a an integer.

Bitwise Operations

This includes bitwise AND, OR, NOT and XOR operations.

Changing Colorspaces

This is done via cvtColor which converts an image from one color space to another.

RGB to Grayscale

RGB to HSV


Refrences

  1. OpenCV documentation